package com.easyfun.healthmagicbox.comm.json;

import org.json.JSONException;
import org.json.JSONObject;

import com.easyfun.healthmagicbox.pojo.Picture;

public class PictureJsonWrapper <T extends JsonWrapper,E> 
	extends AbstractJsonWrapper<T,Picture>{

	public PictureJsonWrapper(Picture pp)
	{
		super(pp);
	}

	public PictureJsonWrapper()
	{
		
	}
 
    public void deserializeFromObj(JSONObject obj) throws JSONException {

    	if (mpp==null)
    		mpp = new Picture();
    	mpp.setPersonID(obj.getString("personID"));    	
    	mpp.setCreated(obj.getString("picCreated"));
    	mpp.setDescription(obj.getString("description"));
    	mpp.setFilename(obj.getString("filename"));

    	if (obj.isNull("id"))
    	{
    		mpp.setSyncid(Integer.valueOf(0));
    	}else
    		mpp.setSyncid(obj.getInt("id"));
    }
 
    
 
    public JSONObject serializeToObj() throws JSONException {
        JSONObject serializedObj = new JSONObject();
        serializedObj.put("personID", mpp.getPersonID());
        serializedObj.put("picCreated", mpp.getCreated());
        serializedObj.put("description", mpp.getDescription());
        serializedObj.put("filename", mpp.getFilename());
 
        return serializedObj;
    }

}
